/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pojo.ThongTinPoJo;
import util.DataProvider;

/**
 *
 * @author Kanet
 */
public class ThongTinDao {
    public static ArrayList<ThongTinPoJo> LayDanhSach(){
        ArrayList<ThongTinPoJo> danhSach= new ArrayList<ThongTinPoJo>();
        String str ="SELECT * FROM thongtin";
        DataProvider dp=new DataProvider();
        dp.open();
        try {
            ResultSet rs = dp.executeQuery(str);
            danhSach=new ArrayList<ThongTinPoJo>();
            ThongTinPoJo tt=null;
            while (rs.next()) {
                tt=new ThongTinPoJo();
                tt.setIdThongTin(rs.getInt("idThongTin"));
                tt.getDanhMuc().setTenDanhMuc(rs.getString("tenDanhMuc"));
                tt.getNhanThongTin().setIdNhanThongTin(rs.getInt("idNhanThongTin"));
                tt.getNhanThongTin().getKhuVuc().setTenKhuVuc(rs.getString("tenKhuVuc"));               
                tt.getNhanThongTin().getTaiKhoan().getPhanhe().setTenPhanHe(rs.getString("tenPhanHe"));
                tt.getNhanThongTin().getTaiKhoan().getPhanhe().setIdPhanhe(rs.getInt("idPhanHe"));
                danhSach.add(tt);
            }
            dp.close();
        } catch (SQLException ex) {
          System.out.println(ex.getMessage());
        }
        return danhSach;
    }
}
